<?php

namespace Core\Data\SQL;

class FieldInformation {

    private $_Name;
    private $_Type;
    private $_Size;
    private $_Null;
    private $_AutoIncrement = false;
    private $_PrimaryKey = false;

    function __get ( $strName ) {

        switch ( $strName ) {

            case "Name":
                return $this->_Name;

            case "Type":
                return $this->_Type;

            case "Size":
                return $this->_Size;

            case "Null":
                return ( $this->_AutoIncrement ) ? false : $this->_Null;

            case "AutoIncrement":
                return $this->_AutoIncrement;

            case "PrimaryKey":
                return $this->_PrimaryKey;

        }

    }

    function __set ( $strName, $mixValue ) {

        switch ( $strName ) {

            case "Name":
                $this->_Name = (string) $mixValue;
                break;

            case "Type":
                $this->_Type = strtoupper( $mixValue );
                break;

            case "Size":
                if ( !is_integer( $mixValue ) and $mixValue !== null ) {
                    throw new \Exception (); // TODO: Fill out this.
                }
                $this->_Size = $mixValue;
                break;

            case "Null":
                if ( !is_bool( $mixValue ) ) {
                    throw new \Exception (); // TODO: Fill out this.
                }
                $this->_Null = $mixValue;
                break;

            case "AutoIncrement":
                if ( !is_bool( $mixValue ) ) {
                    throw new \Exception (); // TODO: Fill out this.
                }
                $this->_AutoIncrement = $mixValue;
                break;

            case "PrimaryKey":
                if ( !is_bool( $mixValue ) ) {
                    throw new \Exception (); // TODO: Fill out this.
                }
                $this->_PrimaryKey = $mixValue;
                break;

        }

    }

}

?>
